﻿@model ARMS.Models.Booking

@{
    ViewBag.Title = "View booking";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@{
    List<SelectListItem> customers = (List<SelectListItem>)ViewData.Eval(ARMS.BaseClasses.Factory.LCUSTOMERS);
    List<SelectListItem> services = (List<SelectListItem>)ViewData.Eval(ARMS.BaseClasses.Factory.LSERVICES);
    List<SelectListItem> workers = (List<SelectListItem>)ViewData.Eval(ARMS.BaseClasses.Factory.LWORKERS);
    ARMS.Models.Shop shop = (ARMS.Models.Shop)ViewData.Eval(ARMS.BaseClasses.Factory.CSHOP);
    string shopName = (shop != null) ? shop.name : "";
}

<h2>Booking details</h2>

<div id="shopinfo">
    Shop: @{ @Html.Raw(String.Format("<span>{0}</span>", shopName)); }
</div>

@Html.ValidationSummary(true, "Please correct the errors and try again.")

@using(Html.BeginForm("DetailSave", "Booking")) 
{
<fieldset>
    <div class="detail">
    @{
        @Html.LabelFor(m => m.id);
        
        if (Model.id > 0) {
            @Html.TextBoxFor(m => m.id, new { @readonly = true, @style = "border: 0px!important;" });
        }else{
            @Html.Raw("<span>NEW BOOKING</span>");
        }

        @Html.Raw("<br />");
        

        @Html.LabelFor(m => m.customername);
        if (customers == null) {
            @Html.TextBoxFor(m => m.customername, new { @readonly = true, @style="border: 0px!important;"  });
            @Html.HiddenFor(m => m.customerid);
            @Html.ValidationMessageFor(m => m.customerid)
        }else{        
            @Html.DropDownListFor(m => m.customerid, customers);
            @Html.ValidationMessageFor(m => m.customerid)
        }
        @Html.Raw("<br />");

        @Html.LabelFor(m => m.workerid);
        @Html.DropDownListFor(m => m.workerid, workers);
        @Html.ValidationMessageFor(m => m.workerid)
        @Html.Raw("<br />");

        
        @Html.LabelFor(m => m.serviceid);
        @Html.DropDownListFor(m => m.serviceid, services);
        @Html.HiddenFor(m => m.serviceid);
        @Html.ValidationMessageFor(m => m.serviceid)
        @Html.Raw("<br />");
                       
        @Html.LabelFor(m => m.note);
        @Html.TextAreaFor(m => m.note, new { cols = 60, @rows = 8 });
        @Html.ValidationMessageFor(m => m.note);
        @Html.Raw("<br />");

        @Html.LabelFor(m => m.datestamp);
        @Html.EditorFor(m => m.datestamp);
        @Html.Raw("<br />");
        @Html.ValidationMessageFor(m => m.datestamp)

        @Html.Raw("<br />");
        @Html.LabelFor(m => m.active);
        @Html.Raw(String.Format("<span>{0}</span>", (Model.active)? "Scheduled":" Not scheduled "));
        @Html.HiddenFor( m => m.active, new { @value = Model.active, @id = "active" });

        @Html.HiddenFor(m => m.shopid);
    }
    </div>
    <div class="detail buttons">
        <button class="dialog-btn" id="cancel" type="button" value="Cancel">@{@Html.ActionLink("Cancel", "Index", "Booking");}</button>
        <button class="dialog-btn" id="save" type="submit" value="Save">Save</button>
    </div>
</fieldset>
    <div class="instruction clear">
        * Please note that all the fields with asterisks are required values.<br />
        If you would like to change the the customer create new booking, this one can be canceled insted.
    </div>
}